package com.atguigu.spring.webflux.reactor8;

import org.junit.jupiter.api.Test;

import java.util.Observable;

/**
 * @author yanglin
 * @create 2023-12-13 16:10 星期三
 * description:
 */
public class ObserverDemo extends Observable {
    
    @Test
    public void test(){
        ObserverDemo observer = new ObserverDemo();
        //添加观察者
        observer.addObserver((o,args) -> {
            System.out.println("发生了变化");
        });

        observer.addObserver((o,args) -> {
            System.out.println("收到被观察者的通知，准备发生改变");
        });
        
        //监控到数据变化
        observer.setChanged();
        
        //通知
        observer.notifyObservers();
    }
    
}
